import { schools, buildings, floors } from './database.mjs'
export const getFloorTree = (type = 'student') => {
  const root = {
    value: 1,
    label: '根部门',
    type: 'root'
  }
  const temp = buildings.filter((b) => b.type == type)
  root.children = schools.map((sc) => ({
    value: sc.id,
    label: sc.name,
    type: 'school',
    children: temp
      .filter((b) => b.school == sc.id)
      .map((b) => ({
        value: b.id,
        label: b.name,
        type: 'building',
        children: floors
          .filter((f) => f.building == b.id)
          .map((f) => ({
            value: f.id,
            label: f.name,
            type: 'floor'
          }))
      }))
  }))

  return [root]
}
